package com.gec.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.system.SysLoginLog;
import com.gec.model.vo.SysLoginLogQueryVo;
import com.gec.system.service.SysLoginLogService;
import com.gec.system.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("登录日志控制器")
@RestController
@RequestMapping("/admin/system/sysLoginLog")
public class SysLoginLogController {
    @Autowired
    private SysLoginLogService sysLoginLogService;

    @ApiOperation(value = "获取分页列表")
    @GetMapping("{page}/{limit}")
    public Result QueryLoginLog(
            @PathVariable Long page,
            @PathVariable Long limit,
                    SysLoginLogQueryVo sysLoginLogQueryVo) {

        IPage<SysLoginLog> iPage = sysLoginLogService.selectPage(page, limit, sysLoginLogQueryVo);
        return Result.ok(iPage);
    }


//    //分页和条件查询
//    @ApiOperation("分页和条件查询")
//    // 分页和条件查询
//    @GetMapping("/{page}/{limit}")
//    public Result findMovieByPageQuery(@PathVariable Long page,
//                                       @PathVariable Long limit,
//                                       SysMovieQueryVo sysMovieQueryVo) {
//        //1.创建分页对象
//        IPage<SysMovie> p1 = new Page<SysMovie>(page, limit);
//        //2.调用方法
//        p1 = this.sysMovieService.selectPage(p1, sysMovieQueryVo);
//        //3.返回
//        return Result.ok(p1);
//    }

    @ApiOperation(value = "获取")
    @GetMapping("get/{id}")
    public Result get(@PathVariable Long id) {
        SysLoginLog sysLoginLog = sysLoginLogService.getById(id);
        return Result.ok(sysLoginLog);
    }

    @ApiOperation("删除")
    @DeleteMapping("removeLoginById/{id}")
    public Result removeLogin(@PathVariable Long id) {
        boolean isOk = sysLoginLogService.removeLoginById(id);
        return isOk ? Result.ok() : Result.fail();
    }

}
